use winit::{
    dpi::PhysicalSize,
    event::{Event, WindowEvent},
    event_loop::{ControlFlow, EventLoop},
    window::WindowBuilder,
};

use bliquez::{Renderer, Scene};

fn main() {
    let el = EventLoop::new().unwrap();
    let window = WindowBuilder::new()
        .with_title("Staria")
        .with_inner_size(PhysicalSize {
            width: 800,
            height: 800,
        })
        .build(&el)
        .unwrap();

    let mut renderer = Renderer::new(&window, 800, 800);

    let mut scene = Scene::new();

    el.set_control_flow(ControlFlow::Poll);
    el.run(|event, target| match event {
        Event::WindowEvent {
            event: WindowEvent::CloseRequested,
            ..
        } => target.exit(),
        Event::AboutToWait => {
            window.request_redraw();
        }
        Event::WindowEvent {
            event: WindowEvent::KeyboardInput { event, .. },
            ..
        } => if event.state.is_pressed() {},
        Event::WindowEvent {
            event: WindowEvent::Resized(size),
            ..
        } => {
            renderer.resize(size.width, size.height);
        }
        Event::WindowEvent {
            event: WindowEvent::RedrawRequested,
            ..
        } => renderer.render(&mut scene),
        _ => (),
    })
    .unwrap();
}
